import {iMicroApp} from "@peryl/micro-web";
import {MicroAppModule} from "./MicroAppModule";

export const microAppLogin = MicroAppModule.createRegistration((option): iMicroApp['login'] => {
  const defaultLogout = () => {
    option.cache.clear();
    option.state.tabs = [];
    option.route.history.push('/login');
  };
  return {
    logout: () => {
      if (option.config.logout) {
        option.config.logout(defaultLogout);
      } else {
        defaultLogout();
      }
    }
  };
});
